<template>
  <div>
    <ElDialog v-model="visible" title="待提交信息">

      <ul>
        <li>编号：{{ bill.leaveBillCode }}</li>
        <li>申请人：{{ bill.applier }}</li>
        <template v-for="(e, i) in leavetypes" :key="i">
          <li v-if="bill.leaveType == e.states">请假类型：{{ e.text }}</li></template
        >
        <li>请假原因：{{ bill.reason }}</li>
        <li>起始时间：{{ bill.timeStart }}</li>
        <li>结束时间：{{ bill.timeEnd }}</li>
      </ul>
      <ElButton type="primary" @click="sub()">确认</ElButton>
    </ElDialog>
    
  </div>
</template>
<script lang="ts">
/**
 * 页面核心数据结构体说明文档
 *
 *
 */
// import from
export type LeaveType = 'sick' | 'issue' | 'annual'
export type BillStates = 'toSubmit' | 'toAudit' | 'auditted'
export type LeaveBill = {
  leaveBillCode: string
  leaveType: LeaveType
  timeStart: Date | null
  timeEnd: Date | null
  reason: string | null
  applier: string | null
  applyTime: Date | null
  auditor: string | null
  auditWord: string | null
  auditTime: Date | null
  resentTimes: number
  billState: BillStates
  modifyTime: Date | null
}
export default {
  name: 'LeaveSubmit',
  props: {
    sampleP: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      sampleD: 'value',
      visible: false,
      code: '',
      bill: {} as LeaveBill,
      leavetypes: [
        { states: 'sick', text: '病假' },
        { states: 'issue', text: '事假' },
        { states: 'annual', text: '年假' }
      ],
      emit: ['putSubmit', 'rpagenum']
    }
  },
  computed: {
    /* sampleC() {
      return this.sampleD + "--";
    }, */
  },
  created() {},
  mounted() {},
  methods: {
    // sampleM() {},
    async sub(){
await   axios({
        method: "PUT",
        url: "http://127.0.0.1:7001/leave/submit/"+this.bill.leaveBillCode,
      }).then(
        (res) => {
         console.log(res);
         ElMessage.success("提交成功")
         this.visible=false
         this.$emit('putSubmit')
        },
        (error) => {
          console.log(error.response.data);
          ElMessage.warning(error.response.data)
   
        }
      );
    }
  },
  watch: {
    // sampleP(n, o) {},
  }
}
</script>

<!--<style scoped>-->
<style lang="scss" scoped></style>
